<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>画廊上传</title>
<style>
a{color:#3b5998;}
</style>
</head>
<body style="font-family:'微软雅黑','宋体',verdana;font-size:14px;">
<div style="width:600px;margin:0 auto;padding-top:50px;">
	<div>
		<h3 style="font-size:16px;padding:5px;border-bottom:solid 1px #ccc;">图片上传</h3>
		
		<form enctype="multipart/form-data" method="post" name="upform" target="upload_target" action="upload.php">
		<input type="file" name="Filedata" id="Filedata"/>
		<input style="margin-right:20px;" type="submit" name="" value="上传" onclick="return checkFile();" /><span style="visibility:hidden;" id="loading_gif"><img src="loading.gif" align="middle" />上传中，请稍侯...</span>
		</form>
		<iframe src="about:blank" name="upload_target" style="display:none;"></iframe>
		<div id="avatar_editor"></div>
		<script type="text/javascript">
			//允许上传的图片类型
			var extensions = 'jpg,jpeg,gif,png';
			//保存缩略图的地址.
			var saveUrl = '/thumb_editor/gallery_save_thumb.php';
			//头像编辑器flash的地址.
			var editorFlaPath = '/thumb_editor/galleryThumbEditor.swf';
			
			function buildAvatarEditor(pic_id,pic_path,post_type)
			{
				var content = '<embed height="464" width="514"'; 
				content+='flashvars="type='+post_type;
				content+='&photoUrl='+pic_path;
				content+='&photoId='+pic_id;
				content+='&saveUrl='+saveUrl+'?radom=1"';
				content+=' pluginspage="http://www.macromedia.com/go/getflashplayer"';
				content+=' type="application/x-shockwave-flash"';
				content+=' allowscriptaccess="always" quality="high" src="'+editorFlaPath+'"/>';
				document.getElementById('avatar_editor').innerHTML = content;
			}
				
						
			/**
			 * 提供给FLASH的接口：编辑头像保存成功后的回调方法
			 */
			function avatarSaved(msg){
				alert('保存成功:' + msg);
				//window.location.href = '/profile.do';
			}
			
			/**
			 * 提供给FLASH的接口：编辑头像保存失败的回调方法, msg 是失败信息，可以不返回给用户, 仅作调试使用.
			 */
			function avatarError(msg){
				alert("上传失败:"+msg);
			}

			function checkFile()
			{
				var path = document.getElementById('Filedata').value;
				var ext = getExt(path);
				var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
				if(extensions != '' && (re.exec(extensions) == null || ext == '')) {
					alert('对不起，只能上传jpg, gif, png类型的图片');
					return false;
				}
				showLoading();
				return true;
			}

			function getExt(path) {
				return path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
			}
            function showLoading()
			{
				document.getElementById('loading_gif').style.visibility = 'visible';
			}
			function hideLoading()
			{
				document.getElementById('loading_gif').style.visibility = 'hidden';
			}
		</script>
	</div>
</div>

</body>

</html>